/*
 * @Author: your name
 * @Date: 2021-07-07 15:01:29
 * @LastEditTime: 2022-11-16 11:06:40
 * @LastEditors: 11 11
 * @Description: In User Settings Edit
 * @FilePath: \exc-tl1-2\SRC\user_src\myQueue.h
 */
#ifndef MYQUEUE_H
#define MYQUEUE_H

#include "stdio.h"
#include "stdlib.h"
#include "stdbool.h"
#include "stdint.h"

#define BYTE uint8_t
#define BOOL bool
#define TRUE true
#define FALSE false

typedef uint8_t QElementType;

/**
 * In order to use the Queue module, a variable of this type must be declared before calling
 * \ref ZW_util_queue_Init.
 */
typedef struct
{
  uint8_t out;          //??????????
  uint8_t in;           //??????????
  uint8_t count;        //???????????
  uint8_t queueSize;    //????
  uint8_t elementType;  //?????,??????????
  QElementType *array;  //????????????
} QUEUE_T;

/**
 * @brief Initializes a given queue with a given buffer.
 * @param[in] pQueue Pointer to the queue to initialize.
 * @param[in] pBuffer Pointer to a buffer to initialize the queue with.
 * @param[in] sizeOfElements Size of elements in the given buffer.
 * @param[in] numberOfElements Number of elements in the given buffer.
 */
void queue_Init(QUEUE_T *pQueue, void *pBuffer, BYTE sizeOfElements, BYTE numberOfElements);

/**
 * @brief Enqueues a given element to a given queue.
 * @param[in] pQueue Pointer to a queue.
 * @param[in] pElement Pointer to an element.
 * @return TRUE if element was enqueued, FALSE otherwise.
 */
BOOL queue_Enqueue(QUEUE_T *pQueue, void *pElement);

/**
 * @brief Dequeues a given element from a given queue.
 * @param[in] pQueue Pointer to a queue.
 * @param[out] pElement Pointer to an element.
 * @return TRUE if element was dequeued, FALSE otherwise.
 */
BOOL queue_Dequeue(QUEUE_T *pQueue, void *pElement);

/**
 * @brief Get number of elements in queue.
 * @param[in] pQueue Pointer to a queue.
 * @return Number of queue elements.
 */
uint8_t queue_GetItemCount(QUEUE_T *pQueue);

#endif
